home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19981211-19990422 / 000345_news@watsun.cc.columbia.edu _Wed Mar 10 20:36:45 1999.msg < prev    next >
Internet Message Format  |  2020-01-01  |  6KB

  1. Return-Path: <news@watsun.cc.columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id UAA01257
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Wed, 10 Mar 1999 20:36:45 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id UAA11089
  7.     for kermit.misc@watsun.cc.columbia.edu; Wed, 10 Mar 1999 20:08:21 -0500 (EST)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Subject: Re: C-Kermit Scripting using INPUT and LOG SESSION
  11. Date: 11 Mar 1999 01:08:19 GMT
  12. Organization: Columbia University
  13. Message-ID: <7c7523$aqe$1@newsmaster.cc.columbia.edu>
  14. To: kermit.misc@mailrelay2.cc.columbia.edu
  15.  
  16. In article <36e7118d.0@amhnt2.amherst.edu>,  <jwmanly+news@amherst.edu> wrote:
  17. : I have some questions about how C-Kermit handles its internal buffers,
  18. : because I'm seeing some behavior that suggests it is more complex than I
  19. : thought.  In particular, I see in the C-Kermit help that there are separate
  20. : CLEAR command for DEVICE and INPUT, and I guess what I could use is some
  21. : information on how these two buffers are related -- that is, how does
  22. : information get moved from one to the other, and which one does LOG SESSION
  23. : read out of?
  24. The device buffer contains stuff that has not yet been read by Kermit.
  25. Kermit reads stuff out of the device buffer when it is in CONNECT mode or when
  26. you give it an INPUT command (and of course when you transfer files, DIAL,
  27. etc).
  28.  
  29. The INPUT buffer (a.k.a. \v(input)) is Kermit's internal circular buffer
  30. that stores the characters most recently read by INPUT commands.
  31.  
  32. : Basically, I'm trying to use C-Kermit to transmit some HTML form data to a
  33. : web-server, and extract a portion of the resulting returned web page.  I'm
  34. : sending the form data via the TRANSMIT command.  The web page that comes
  35. : back looks like this:
  36. : HTTP/1.1 200 OK
  37. : blah blah blah<p>
  38. : blah blah blah<p>
  39. : <font size="7"...<p>
  40. : THE DATA I WANT TO CAPTURE<p>
  41. : blah blah blah<p>
  42. : blah blah blah<p>
  43. : </html>
  44. : What I want is to capture the "THE DATA I WANT TO CAPTURE<p>" piece in an 
  45. : external file for further processing outside of Kermit.  I thought this
  46. : would be pretty easy: Just connect to the server, transmit the form data to
  47. : it, do an INPUT for the |<font size="7"| string, another INPUT to advance
  48. : to the following |<p>| string, turn on session logging, do another INPUT
  49. : for the |<p>| string, turn off logging, hangup and exit.
  50. : Well, needless to say it hasn't been this straightforward, and the results
  51. : don't even seem to be consistent. It is as if the LOG SESSION command is
  52. : working out of a buffer that is somehow different (or not synchronized)
  53. : with the one the INPUT command is using.  My actual script is down below,
  54. : but before we get to that, I've stumbled over some other strangeness as
  55. : I've tried to debug this issue, so let's go over those first.
  56. : Consider the following script:
  57. : ---------------------------------------------------------------------------
  58. : set host www.qrz.com:80
  59. : set input echo off
  60. : set transmit echo off
  61. : set transmit prompt 0
  62. : clear
  63. : transmit form.txt
  64. : log session form.out
  65. : pause 10
  66. : log session
  67. : hangup
  68. : exit
  69. : ---------------------------------------------------------------------------
  70. : This seems about as simple as it gets: transmit the form data, start
  71. : logging the session, wait 10 seconds for everything to come through, exit.
  72. : This should record everything that comes back.  But it doesn't.  In fact,
  73. : it doesn't record anything.  BUT, if I replace that "PAUSE 10" command with
  74. : an "INPUT 10 XXXXXXX" string, THEN it works.  
  75. : Why is this?
  76. :
  77. Because after you "transmit form.txt", you are not executing any Kermit
  78. commands that read from the connection.
  79.  
  80. : Why the necessity for the INPUT line? I assume it is to force
  81. : C-Kermit to somehow "consume" or "process" the information, but is there
  82. : any other, cleaner way to do that?
  83. No.  You have to think of INPUT as an analog for your eyes and brain.
  84. If you were in CONNECT mode, you'd watch the stuff coming in, and eventually
  85. you would see something that tells you it's done.  No INPUT, no eyes (and
  86. no brain :-)
  87.  
  88. (OUTPUT is an analog for your fingers, and some would say also for your
  89. brain, but others -- especially readers of certain newsgroups (not this one)
  90. might disagree :-)
  91.  
  92. : OK, on to my real problem.  Consider the script below, the one to solve the
  93. : problem I describe at the start of my message:
  94. : ---------------------------------------------------------------------------
  95. : set host www.qrz.com:80
  96. : set input echo off
  97. : set transmit echo off
  98. : set transmit prompt 0
  99. : clear
  100. : transmit form.txt
  101. : input 10 <font size="7"
  102. : input 10 <p>
  103. : log session form.out
  104. : input 10 <p>
  105. : log session
  106. : input 10 </html>
  107. : hangup
  108. : exit
  109. : ---------------------------------------------------------------------------
  110. : This doesn't work reliably, though it does work sometimes.  
  111. :
  112. So maybe it's time-dependent.  Something that takes 10 seconds one day on
  113. the Internet might take an hour on another day.  You need IF FAIL tests
  114. after every INPUT.
  115.  
  116. : Final question: notice how I put that "INPUT 10 </html>" command at the end
  117. : of the script to flush out whatever other data comes back from the remote
  118. : server following the part that I am intersted in?  If I don't do this, when
  119. : I hit the EXIT at the end of the script (even though it follows the HANGUP
  120. : command), I get the "There may still be a connection open, OK to exit?"
  121. : message when the script finishes.  I assume this is because there is
  122. : "unconsumed" data in the buffer.
  123. :
  124. It's because the connection is still open, just like it says.  The server
  125. closes the connection after all the data it sent has been acknowledged
  126. (at the TCP level).
  127.  
  128. : How do I tell Kermit to drop the
  129. : connection regardless of whether there is anything left in the buffer or
  130. : not, even if data is still streaming in?
  131. Like it says in the book:
  132.  
  133.   SET EXIT WARNING OFF
  134.  
  135. There are some examples in the book that should clarify matters.  E.g, how
  136. to read a line at a time from the host and write each line to file as it
  137. comes in.
  138.  
  139. - Frank